<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="成本核算表" />
<%@ include file="../inc/PrintTitle.jsp"%>
<head>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doDownload(){
		window.location="/business/BusinessProfitDetail.ihtm?id=${bill.id}&content_type=EXCEL";
	}
	function doPrint(){
		ShowConfirm('确认框','确定开始打印吗？',340,80,"doPrintCallBack()");
	}
	function doPrintCallBack(){
		if(popRetVal!=null){
			document.getElementById("noPrinSpan").style.display="none";
			printContent("管理易-成本核算表","${enterpriseInfo.doPrint}","${enterpriseInfo.printWidth}");
			document.getElementById("noPrinSpan").style.display="";
		}
	}
	function doCancel(){
		window.close();
	}
</script>
</head>
<body style="background-color:#FFFFFF">
<table width="100%" border="0"  align="center" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td height="40px" align="center" class="FontLarge_Bold">${licenseInfo.enterpriseName} 成本核算表</td>
				</tr>
		  </table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" width="33%">客户名称：${est.estName}</td>
			      	<td class="FontSmall" width="33%">业务单号：${bill.billCode}</td>
			      	<td class="FontSmall" width="34%">订货日期：<fmt:formatDate value="${bill.orderDate}" pattern="yyyy-MM-dd"/></td>
				</tr>
				<tr class="ListTrPrint">
					<td class="FontSmall">合同金额：${bill.cost}</td>
				  	<td class="FontSmall" colspan="2">摘要：${bill.content}</td>
			    </tr>
			    <tr class="ListTrPrint">
					<td class="FontSmall">已调账：${be.adjustCost}</td>
				  	<td class="FontSmall">已收金额：${be.collectedCost}</td>
				  	<td class="FontSmall">欠款：${bill.cost+be.adjustCost-be.collectedCost}</td>
			    </tr>
			    <tr class="ListTrPrint">
					<td class="FontSmall">成本合计：${profit.materialCost+profit.cooperCost+profit.feeCost}</td>
				  	<td class="FontSmall">毛利率：${percent}%</td>
				  	<td class="FontSmall">毛利：${profit.profitCost}</td>
			    </tr>
		  	</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td class="FontSmall_Bold" height="30">材料项目（小计：${profit.materialCost}）</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="small_border">
				<tr class="ListTrPrint">
					<td class="FontSmall_Bold" align="center" width="10%">日期</td>
					<td class="FontSmall_Bold" align="center" width="16%">单号</td>
					<td class="FontSmall_Bold" align="center" width="18%">供/需方</td>
					<td class="FontSmall_Bold" align="center" width="6%">出/入</td>
					<td class="FontSmall_Bold" align="center" width="10%">材料编号</td>
					<td class="FontSmall_Bold" align="center" width="20%">品名规格</td>
					<td class="FontSmall_Bold" align="center" width="7%">单位</td>
					<td class="FontSmall_Bold" align="center" width="6%">数量</td>
					<td class="FontSmall_Bold" align="center" width="7%">金额</td>
				</tr>
				<c:if test="${fn:length(ioList)==0}">
				<tr class="ListTrPrint">
					<td class="FontSmall" align="center" colspan="9">没有材料项目</td>
				</tr>
				</c:if>
				<c:if test="${fn:length(ioList)>0}">
				<c:forEach var="item" items="${ioList}" varStatus="i">
					<tr class="ListTrPrint">
						<td class="FontSmall" align="center"><fmt:formatDate value="${item.billDate}" pattern="yyyy-MM-dd"/></td>
						<td class="FontSmall" align="center">${item.billCode}</td>
						<td class="FontSmall" align="center">${item.otherName}</td>
						<td class="FontSmall" align="center">
							<c:if test="${item.billType=='IN'}">入</c:if>
				    		<c:if test="${item.billType=='OUT'}">出</c:if>
						</td>
						<td class="FontSmall" align="center">${item.productCode}</td>
						<td class="FontSmall" align="center">${item.productName}</td>
						<td class="FontSmall" align="center">${item.productUnit}</td>
						<td class="FontSmall" align="center">
							<c:if test="${item.billType=='IN'}"><commonTag:parseBigDecimal source="${item.inAmount}" /></c:if>
				    		<c:if test="${item.billType=='OUT'}"><commonTag:parseBigDecimal source="${item.outAmount}" /></c:if>
						</td>
						<td class="FontSmall" align="center">
							<c:if test="${item.billType=='IN'}"><commonTag:parseBigDecimal source="${0-item.inCost}" /></c:if>
							<c:if test="${item.billType=='OUT'}"><commonTag:parseBigDecimal source="${item.outCost}" /></c:if>
						</td>
					</tr>
				</c:forEach>
				</c:if>
		  </table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td class="FontSmall_Bold" height="30">外协项目（小计：${profit.cooperCost}）</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" class="ListTable">
				<tr class="ListTrPrint">
				   	<td class="FontSmall_Bold" align="center" width="8%">日期</td>
					<td class="FontSmall_Bold" align="center" width="12%">单号</td>
					<td class="FontSmall_Bold" align="center" width="10%">项目类型</td>
					<td class="FontSmall_Bold" align="center" width="12%">内容</td>
					<td class="FontSmall_Bold" align="center" width="10%">材质</td>
					<td class="FontSmall_Bold" align="center" width="12%">规格</td>
					<td class="FontSmall_Bold" align="center" width="12%">制作要求</td>
					<td class="FontSmall_Bold" align="center" width="6%">单位</td>
					<td class="FontSmall_Bold" align="center" width="6%">数量</td>
					<td class="FontSmall_Bold" align="center" width="6%">单价</td>
					<td class="FontSmall_Bold" align="center" width="6%">金额</td>
				</tr>
				<c:if test="${fn:length(coopList)==0}">
				<tr class="ListTrPrint">
					<td class="FontSmall" align="center" colspan="11">没有外协项目</td>
				</tr>
				</c:if>
				<c:if test="${fn:length(coopList)>0}">
				<c:forEach var="item" items="${coopList}" varStatus="i">
					<tr class="ListTrPrint">
						<td class="FontSmall" align="center"><fmt:formatDate value="${item[0].cooperDate}" pattern="yyyy-MM-dd"/></td>
						<td class="FontSmall" align="center">${item[0].billCode}</td>
						<td class="FontSmall" align="center"><commonTag:showSimpleObjectName list="${mtList}" objectId="${item[1].makeTypeId}" /></td>
						<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item[1].finishedContent}" /></td>
						<td class="FontSmall" align="center">${item[1].proName}</td>
						<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item[1].specification}" /></td>
						<td class="FontSmall" align="center"><commonTag:parseEnterToBr source="${item[1].makeRequire}" /></td>
						<td class="FontSmall" align="center">
							<c:if test="${item[1].priceType=='AREA'}">平方米</c:if>
							<c:if test="${item[1].priceType=='LENGTH'}">
								<c:if test="${item[1].lengType=='M'}">米</c:if><c:if test="${item[1].lengType=='CM'}">公分</c:if>
							</c:if>
							<c:if test="${item[1].priceType=='AMOUNT'}">${item[1].unit}</c:if>
						</td>
						<td class="FontSmall" align="center">
							<c:if test="${item[1].priceType=='AREA' || item[1].priceType=='LENGTH'}"><commonTag:parseBigDecimal source="${item[1].squareNum}" /></c:if>
							<c:if test="${item[1].priceType=='AMOUNT'}"><commonTag:parseBigDecimal source="${item[1].amount}" /></c:if>
						</td>
						<td class="FontSmall" align="center"><commonTag:parseBigDecimal source="${item[1].unitPrice}" /></td>
						<td class="FontSmall" align="center"><commonTag:parseBigDecimal source="${item[1].cost}" /></td>
					</tr>
				</c:forEach>
				</c:if>
		  </table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td class="FontSmall_Bold" height="30">费用（小计：${profit.feeCost}）</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" class="ListTable">
				<tr class="ListTrPrint">
				   	<td class="FontSmall_Bold" align="center" width="10%">日期</td>
					<td class="FontSmall_Bold" align="center" width="16%">单号</td>
					<td class="FontSmall_Bold" align="center" width="14%">费用类型</td>
					<td class="FontSmall_Bold" align="center" width="10%">金额</td>
					<td class="FontSmall_Bold" align="center" width="25%">备注</td>
					<td class="FontSmall_Bold" align="center" width="10%">经办人</td>
					<td class="FontSmall_Bold" align="center" width="15%">部门</td>
				</tr>
				<c:if test="${fn:length(feeList)==0}">
				<tr class="ListTrPrint">
					<td class="FontSmall" align="center" colspan="7">没有费用</td>
				</tr>
				</c:if>
				<c:if test="${fn:length(feeList)>0}">
				<c:forEach var="item" items="${feeList}" varStatus="i">
					<tr class="ListTrPrint">
						<td class="FontSmall" align="center"><fmt:formatDate value="${item[1]}" pattern="yyyy-MM-dd"/></td>
						<td class="FontSmall" align="center">${item[2]}</td>
						<td class="FontSmall" align="center"><commonTag:showSimpleObjectName list="${ftList}" objectId="${item[0].ftId}" /></td>
						<td class="FontSmall" align="center">${item[0].cost}</td>
						<td class="FontSmall" align="center">${item[0].mark}</td>
						<td class="FontSmall" align="center">${item[3]}</td>
						<td class="FontSmall" align="center"><commonTag:showSimpleObjectName list="${depList}" objectId="${item[4]}" /></td>
					</tr>
				</c:forEach>
				</c:if>
		  </table>
		</td>
	</tr>
	<tr>
		<td>
			<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="ListTable">
				<tr class="ListTrPrint">
			      	<td class="FontSmall" width="33%">业务来源：${bill.introducerName}</td>
			      	<td class="FontSmall" width="33%">跟单员：${followerName}</td>
			      	<td class="FontSmall" width="34%">设计员：${designerName}</td>
				</tr>
				<tr class="ListTrPrint">
			      	<td class="FontSmall">业务员：${bill.managerName}</td>
			      	<td class="FontSmall">&nbsp;</td>
			      	<td class="FontSmall">&nbsp;</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td height="3"></td>
	</tr>
	<tr id="noPrinSpan">
		<td>
			<table width="98%" border="0" cellspacing="1" cellpadding="1" align="center">
				<tr>
					<td>
						<input type="button" id="printButton" class="Button" value="开始打印 " onClick="doPrint();">
						<input type="button" id="printButton" class="Button" value=" 导 出 " onClick="doDownload();">
						<input type="button" id="cancelButton" class="Button" value=" 退 出 " onClick="doCancel();">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</body>
</html>